<%@ page import="com.dao.UserDao" %>
<%@ page import="com.bean.User" %>
<%@ page import="java.io.PrintWriter" %>
<%@ page import="com.bean.Group" %>
<%@ page import="com.dao.GroupDao" %>
<%@ page import="websocket.chat.GloabStatus" %>
<%@ page import="com.util.QQUtils" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<%
  String qq = request.getParameter("qq");
  String groupQQ = request.getParameter("groupQQ");

  GroupDao groupDao = new GroupDao();
  PrintWriter writer =response.getWriter();
  Group group = groupDao.getGroupOneByQQ(groupQQ);
  if(group.getId()==0){
      writer.write("-1");
  }else {
    StringBuffer sb = new StringBuffer();
    sb.append("{").append("\"groupQQ\":"+"\""+group.getQq()+"\"").append(",")
            .append("\"groupName\":"+"\""+group.getName()+"\"").append(",")
            .append("\"userId\":"+"\""+group.getUserId()+"\"").append(",")
            .append("\"manager\":"+"\""+ QQUtils.getQunzhu(group.getUserId(),group)+"\"").append(",")
            .append("\"userList\":").append("[");
            for (User user:group.getUserList()){
              sb.append("{").append("\"userName\":"+"\""+user.getUsername()+"\"").append(",");
              sb.append("\"userQQ\":"+"\""+user.getQq()+"\"").append(",");
              sb.append("\"headPic\":"+"\""+user.getHeadPic()+"\"").append(",");
              sb.append("\"sex\":"+"\""+user.getSex()+"\"").append(",");
              sb.append("\"status\":"+"\""+ GloabStatus.status(user.getQq())+"\"").append(",");
              sb.append("\"age\":"+"\""+user.getAge()+"\"").append("}").append(",");
            }
            sb.deleteCharAt(sb.lastIndexOf(","));
            sb.append("]}");

    writer.write(sb.toString());
  }
  writer.close();
%>